package com.qzn.backend.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.qzn.backend.dao.ReportDao;
import com.qzn.backend.dto.DoReportDto;
import com.qzn.backend.dto.GetReportDto;
import com.qzn.backend.dto.item.GetReportResultItemDto;

@Service
public class ReportService {

	@Autowired
	private ReportDao reportDao;

	public void doReport(DoReportDto reportDto) {
		reportDao.insertReport(reportDto);
	}

	public int getReportCount(GetReportDto reportDto) {
		// 如果user为空，则查询全部
		if (StringUtils.isEmpty(reportDto.getUser())) {
			return reportDao.selectReportAllCount(reportDto);
		} else {
			return reportDao.selectReportUserCount(reportDto);
		}
	}

	public List<GetReportResultItemDto> getReport(GetReportDto reportDto) {

		// 如果user为空，则查询全部
		if (StringUtils.isEmpty(reportDto.getUser())) {
			return reportDao.selectReportAll(reportDto);
		} else {
			return reportDao.selectReportUser(reportDto);
		}
	}

	public Map<String, byte[]> getMedia(String id) {
		return reportDao.getMedia(id);
	}

	public void verify(String id) {

		reportDao.verify(id);
	}
}
